package cn.ekuma.epos.datalogic.define.dao.oa.ext;

import java.util.List;
import com.openbravo.bean.oa.AttenceExt;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.QBFBuilder;
import com.openbravo.data.loader.SerializerWriteBasic;
import com.openbravo.data.loader.StaticSentence;
import cn.ekuma.data.dao.ViewDAO;
import cn.ekuma.epos.datalogic.define.dao.UserInfoDAO;
import cn.ekuma.epos.datalogic.define.dao.oa.AttenceDAO;
import cn.ekuma.epos.db.table.oa.I_Attence;

public class AttenceExtDAO extends ViewDAO<AttenceExt>{
	UserInfoDAO userInfoDAO;
	AttenceDAO attenceDAO;
	
	public AttenceExtDAO(I_Session s,UserInfoDAO userInfoDAO,AttenceDAO attenceDAO) {
		super(s);
		this.userInfoDAO=userInfoDAO;
		this.attenceDAO=attenceDAO;
	}

	@Override
	public Class getSuportClass() {
		return AttenceExt.class;
	}

	@Override
	public AttenceExt readValues(DataRead dr, AttenceExt obj)
			throws BasicException {
		if(obj==null)
			obj=new AttenceExt();
		attenceDAO.readValues(dr, obj);
		obj.setUserInfo(userInfoDAO.loadPeopleByID(obj.getUserId()));
		return obj;
	}

	@Override
	public List<AttenceExt> list(Object filter) throws BasicException {
		return new StaticSentence(s, new QBFBuilder(attenceDAO.getTableDefinition().getListSQL()+" WHERE ?(QBF_FILTER) "
                + "ORDER BY CREATEDATE", new String[]{I_Attence.CREATEDATE, I_Attence.CREATEDATE, I_Attence.USER_ID,I_Attence.ATTENCE_NAME}), new SerializerWriteBasic(new Datas[]{Datas.OBJECT, Datas.TIMESTAMP, Datas.OBJECT, Datas.TIMESTAMP, Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.STRING}), this).list(filter);

	}
	
	
	
}
